[%
<wizard>
	<page>
		<title>Select data type</title>
		<description>Select data type for which to create a strongly typed collection
					 (for value types, remember to use a pointer, e.g. "String *")</description>
		<variable name="datatype"/>
	</page>	
</wizard>
%]
#include "stdafx.h"

#using <mscorlib.dll>
using namespace System;
using namespace System::Collections;

public __gc class [%<variable type="standard" name="filenamebase"/>%] : public CollectionBase 
{
public:
	__property [%<variable type="custom" name="datatype"/>%] get_Item( int index )
	{
		return __try_cast<[%<variable type="custom" name="datatype"/>%]>(List->Item[index]);
		// TODO: If [%<variable type="custom" name="datatype"/>%] is a value type, then replace with this:
		//return *__try_cast<__box [%<variable type="custom" name="datatype"/>%] *>(List->Item[index]);
	}
	__property void set_Item( int index, [%<variable type="custom" name="datatype"/>%] value )
	{
		List->Item[index] = value;		// TODO: If [%<variable type="custom" name="datatype"/>%] is a value type, then replace "value" with "__box(value)"
	}

	int Add([%<variable type="custom" name="datatype"/>%] value)
	{
		return(List->Add(value));	// TODO: If [%<variable type="custom" name="datatype"/>%] is a value type, then replace "value" with "__box(value)"
	}

	int IndexOf([%<variable type="custom" name="datatype"/>%] value) 
	{
		return(List->IndexOf(value));	// TODO: If [%<variable type="custom" name="datatype"/>%] is a value type, then replace "value" with "__box(value)"
	}

	void Insert(int index, [%<variable type="custom" name="datatype"/>%] value) 
	{
		List->Insert(index, value);		// TODO: If [%<variable type="custom" name="datatype"/>%] is a value type, then replace "value" with "__box(value)"
	}

	void Remove([%<variable type="custom" name="datatype"/>%] value)
	{
		List->Remove(value);		// TODO: If [%<variable type="custom" name="datatype"/>%] is a value type, then replace "value" with "__box(value)"
	}

	bool Contains([%<variable type="custom" name="datatype"/>%] value)
	{
		// If value is not of type [%<variable type="custom" name="datatype"/>%], this will return false.
		return(List->Contains(value));	// TODO: If [%<variable type="custom" name="datatype"/>%] is a value type, then replace "value" with "__box(value)"
	}

protected:
	void OnInsert(int index, Object* value) 
	{
		// Insert additional code to be run only when inserting values.
	}

	void OnRemove(int index, Object* value) 
	{
		// Insert additional code to be run only when removing values.
	}

	void OnSet(int index, Object* oldValue, Object* newValue) 
	{
		// Insert additional code to be run only when setting values.
	}

	void OnValidate(Object* value) 
	{
		// This check is commented out since it doesn't work for all types
		//if (value->GetType() != Type::GetType(S"[%<variable type="custom" name="datatype"/>%]"))
		//	throw new ArgumentException(S"value must be of type [%<variable type="custom" name="datatype"/>%].", S"value");
	}
};
